﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using System.Web;
using WebApp.Data;

namespace WebApp.Services
{
    public class BlockSeriesService
    {
        public List<tbl_serie> BlockList(int index,
                                                   int size,
                                                   string sortColumn,
                                                   string sortDirection,
                                                   string keyword,
                                                   ref int count)
        {
            using (var db = new PAVINGDataContext())
            {
                var direction = sortDirection.Equals("desc") ? " descending " : "";

                var mat = db.tbl_series.Where(u => u.series_name.Contains(keyword))
                                              .OrderBy(sortColumn + direction)
                                              .Skip(size * (index - 1)).Take(size);

                count = mat.Count();

                return mat.ToList();
            }
        }
    }
}